<!-- 登录 -->
<template>
  <client-only>
    <el-dialog v-model="showLogin" width="560px" :z-index="1000" draggable @close="resetForm" :show-close="false">
      <template #header="{ close, titleId, titleClass }">
        <div class="header">
          <div :id="titleId" :class="titleClass">
            <template v-if="active === 'login'">登录</template>
            <template v-if="active === 'register'">注册</template>
            <template v-if="active === 'retrieve'">找回密码</template>
          </div>
          <div class="close">
            <el-icon @click="close"><CloseBold /></el-icon>
          </div>
        </div>
      </template>
      <div class="pb-16px">
        <!-- 登录 -->
        <login v-if="active === 'login'" @update="update" @close="resetForm"/>
        <!-- 找回密码 -->
        <retrieve v-if="active === 'retrieve'" @update="update" />
      </div>
    </el-dialog>
  </client-only>
</template>

<script setup>
import login from './login'
import retrieve from './retrieve'

// 获取用户信息
import { storeToRefs } from "pinia";
const user = useStore.user()
const { showLogin } = storeToRefs(user)

const active = ref('login')

const update = (val) => {
  active.value = val
}
const resetForm = () => {
  user.showLogin = false
  active.value = 'login'
}
</script>
<style lang='scss' scoped>
.header{
  text-align: center;
  position: relative;
  padding-top: 16px;
  padding-bottom: 16px;

  .el-dialog__title{
    font-weight: bold;
    font-size: 20px;
    line-height: 26px;
  }

  .close{
    position: absolute;
    width: 32px;
    height: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    right: -22px;
    top:-22px;
    background-color: #fff;
    border-radius: 32px;
    cursor: pointer;
  }
}

::v-deep(.center) {
  .captcha {
    flex: 1;
    margin-right: 10px;
  }

  .toggle {
    display: flex;
    justify-content: flex-end;
  }

  .mt40 {
    margin-top: 40px;
  }


}

.btns {
  >div {
    margin-top: 24px;
  }

  .fullBtn {
    width: 100%;
  }
}

::v-deep(.el-input){
  line-height: 56px;
  
  .el-input__wrapper{
    border-radius: 28px;
  }
  .el-input__inner{
    --el-input-inner-height:calc(56px - 2px) !important;
  }
}
</style>
